﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class register_3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["USERNAME"] == null || Session["PASSWORD"] == null)
            Response.Redirect("register_1.aspx", true);
    }
    
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("register_4.aspx", true);
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        //用Session[USERNAME]找到刚才提交的数据库信息并删除
        string username = Session["USERNAME"].ToString();
        SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["wbkpt"].ConnectionString.ToString());
        sc.Open();
        SqlCommand com1 = new SqlCommand();
        com1.Connection = sc;
        com1.CommandText = "delete from INFO_ENTER where ENTER_NAME=@name";
        com1.Parameters.AddWithValue("@name",username);
        while (Application["sqllock"] == "lock")
        {//检测是否已经锁住               
            System.Threading.Thread.Sleep(2000);
        }
        Application["sqllock"] = "lock";//上锁 
        if (com1.ExecuteNonQuery() == 1)
        {
            Application["sqllock"] = "unlock";//解锁 
            Response.Redirect("register_2.aspx", true);
        }
        else
        {
            Application["sqllock"] = "unlock";//解锁 
            label1.Text = "返回失败，请重试！";
        }
        sc.Close();
    }
}